package com.ywu.standard.menu.api;

import com.ywu.common.result.CommonResult;
import com.ywu.standard.menu.dto.MenuDto;
import com.ywu.standard.menu.dto.MenuPermissionDto;
import com.ywu.standard.menu.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName MenuApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/2/24 19:17
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/menu")
public class MenuApi {
    @Autowired
    private MenuService menuService;

    /**
    * @Author GroundDemo
    * @Description 查询所有菜单信息
    * @Date 19:21 2024/2/24
    * @Param []
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.info")
    public CommonResult<Object> getAllMenuInfo(@RequestBody MenuDto menuDto) {
        return menuService.getAllMenuInfo(menuDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询所有菜单合并子菜单的形式
    * @Date 20:34 2024/2/25
    * @Param []
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.all.info")
    public CommonResult<Object> getAllMenuNoChildrenInfo() {
        return menuService.getAllMenuNoChildrenInfo();
    }

    /**
    * @Author GroundDemo
    * @Description 查询菜单路由信息
    * @Date 11:30 2024/2/25
    * @Param []
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.router.info")
    public CommonResult<Object> getMenuRouterInfo() {
        return menuService.getMenuRouterInfo();
    }

    /**
    * @Author GroundDemo
    * @Description 添加菜单
    * @Date 18:42 2024/2/26
    * @Param []
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.add.info")
    public CommonResult<Object> addMenuInfo(@RequestBody @Valid MenuDto menuDto) {
        return menuService.addMenuInfo(menuDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改菜单
    * @Date 21:14 2024/2/26
    * @Param [menuDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.update.info")
    public CommonResult<Object> updateMenuInfo(@RequestBody @Valid MenuDto menuDto) {
        return menuService.updateMenuInfo(menuDto);
    }

    /**
    * @Author GroundDemo
    * @Description 删除菜单
    * @Date 22:09 2024/2/26
    * @Param [menuDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.delete.info")
    public CommonResult<Object> deleteMenuInfo(@RequestBody @Valid MenuDto menuDto) {
        return menuService.deleteMenuInfo(menuDto);
    }

    /**
     * @Author GroundDemo
     * @Description 菜单组件查询 - 配合前端实现菜单组件的动态注册
     * @Date 22:09 2024/2/26
     * @Param [menuDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/menu.component.register.query.info")
    public CommonResult<Object> menuComponentRegisterQuery(@RequestBody MenuDto menuDto) {
        return menuService.menuComponentRegisterQuery(menuDto);
    }

    /**
    * @Author GroundDemo
    * @Description 更新菜单是否隐藏
    * @Date 19:37 2024/9/21
    * @Param [menuDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/menu.update.isHidden.info")
    public CommonResult<Object> updateMenuIsHidden(@RequestBody MenuDto menuDto) {
        return menuService.updateMenuIsHidden(menuDto);
    }

    /**
    * @Author GroundDemo
    * @Description 更新组件时删除缓存
    * @Date 12:29 2025/7/5
    * @Param [menuDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/delete.menu.register.cache.for.spi")
    public CommonResult<Object> deleteRegisterCache(@RequestBody MenuDto menuDto) {
        return menuService.deleteRegisterCache(menuDto);
    }
}
